package com.gdufe.firesafe.controller;

import com.gdufe.firesafe.annotation.NeedAdmin;
import com.gdufe.firesafe.utils.PageUtils;
import com.gdufe.firesafe.utils.R;
import com.gdufe.firesafe.model.entity.FloorEntity;
import com.gdufe.firesafe.service.FloorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;



/**
 * 楼层表
 *
 * @author Liu
 * @email
 * @date 2024-03-26 16:29:57
 */
@RestController
@RequestMapping("house/floor")
public class FloorController {
    @Autowired
    private FloorService floorService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = floorService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		FloorEntity floor = floorService.getById(id);

        return R.ok().put("floor", floor);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody FloorEntity floor){
		floorService.save(floor);

        return R.ok();
    }

    /**
     * 修改
     */
    @NeedAdmin
    @RequestMapping("/update")
    public R update(@RequestBody FloorEntity floor){
		floorService.updateById(floor);

        return R.ok();
    }

    /**
     * 删除
     */
    @NeedAdmin
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
		floorService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
